package com.example.javadesign.prototype.shallow;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 陳樂
 * @version 1.0.0
 * @ClassName Main.java
 * @Description TODO
 * @createTime 2022年08月21日 20:31:00
 */
public class Main {

    public static void main(String[] args) {
        // 创建原型对象
        ConcretePrototype prototype = new ConcretePrototype();
        prototype.setName("CC");
        prototype.setAge(18);
        List<String> hobbies = new ArrayList<>();
        hobbies.add("书法");
        hobbies.add("音乐");
        prototype.setHobbies(hobbies);
        System.out.println(prototype);

        // 拷贝
        ConcretePrototype clone = prototype.clone();
        clone.getHobbies().add("游戏");
        System.out.println(clone); //克隆对象
        System.out.println(prototype); //原型对象
    }
}
